namespace cbooc

import Boo.Lang.Compiler
import Boo.Lang.Compiler.IO
import Boo.Lang.Compiler.Steps
import Boo.Lang.Parser from Boo.Lang.Parser
import ConcurrentBoo

class ConcurrentParsingStep(AbstractCompilerStep):
	
	static def SetUp(pipeline as CompilerPipeline):
		pipeline.Replace(BooParsingStep, ConcurrentParsingStep())
	
	override def Run():
		for unit as Ast.CompileUnit in cmapU(cmapU(Parameters.Input, ReadAll), Parse):
			assert 1 == len(unit.Modules)
			CompileUnit.Modules.Extend(unit.Modules)
			
	private def ReadAll(input as ICompilerInput):
		using reader=input.Open():
			return StringInput(input.Name, reader.ReadToEnd())
			
	private def Parse(input as ICompilerInput):
		using reader=input.Open():
			return BooParser.ParseReader(input.Name, reader)
		

